# 1、制作图像的元数据，进行保存
import os
import pandas as pd

df = pd.DataFrame(columns=['img_path', 'label'])

for root, dirs, files in os.walk("../dataset"):
    for file in files:
        if file.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp')):
            img_path = os.path.abspath(os.path.join(root, file))
            label = os.path.basename(root)
            # print(img_path, label)
            df = pd.concat([df, pd.DataFrame([[img_path, label]], columns=['img_path', 'label'])],
                           ignore_index=True)

# print(df)
df.to_csv('./meta.csv', index=False, encoding="gbk")